package fcrpt

class StepStatusAnalysisController {
    def dynamicQueryService
    def stepStatusAnalysis() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList = []
        def stepStatusAnalysis = []
        def pageSizeList = [10, 20, 50, 100]
        def totalCount = 0
        def stepStatusAnalysisSum = [];

        if (params.EXPORT_CONTENT_NAME == 'Excel') {
            params.SYS_QUERY_NAME = 'stepStatusAnalysis'
            stepStatusAnalysis = dynamicQueryService.queryForList(params)
            if (stepStatusAnalysis.size() > 0) {
                tableHeadList = stepStatusAnalysis[0].keySet()
            }
            params.SYS_QUERY_NAME = 'stepStatusAnalysisCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

            params.SYS_QUERY_NAME = 'stepStatusAnalysisSum'
            stepStatusAnalysisSum = dynamicQueryService.queryForList(params)
        }

        [startno                   : params.startno ?: '',
         endno                     : params.endno ?: '',
         pageSize                  : pageSize,
         totalCount                : totalCount,
         pageSizeList              : pageSizeList,
         tableHeadList             : tableHeadList,
         stepStatusAnalysis      : stepStatusAnalysis,
         stepStatusAnalysisSum: stepStatusAnalysisSum,
         stepDesc                 : params.stepDesc ?: ''
        ]
    }
    def stepStatusAnalysisTwo() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList = []
        def stepStatusAnalysisTwo = []
        def pageSizeList = [10, 20, 50, 100]
        def totalCount = 0
        def stepStatusAnalysisTwoSum = [];


            params.SYS_QUERY_NAME = 'stepStatusAnalysisTwo'
            stepStatusAnalysisTwo = dynamicQueryService.queryForList(params)
            if (stepStatusAnalysisTwo.size() > 0) {
                tableHeadList = stepStatusAnalysisTwo[0].keySet()
            }
            params.SYS_QUERY_NAME = 'stepStatusAnalysisTwoCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

            params.SYS_QUERY_NAME = 'stepStatusAnalysisTwoSum'
            stepStatusAnalysisTwoSum = dynamicQueryService.queryForList(params)


        print(params.stayTime)
        [startno                   : params.startno ?: '',
         endno                     : params.endno ?: '',
         pageSize                  : pageSize,
         totalCount                : totalCount,
         pageSizeList              : pageSizeList,
         tableHeadList             : tableHeadList,
         stepStatusAnalysisTwo      : stepStatusAnalysisTwo,
         stepStatusAnalysisTwoSum: stepStatusAnalysisTwoSum,
         stepDesc                 : params.stepDesc ?: '',
         docId                 : params.docId ?: '',
         lindId                 : params.lindId ?: '',
         lotId                 : params.lotId ?: '',
         tuhao                 : params.tuhao ?: '',
         state                 : params.state ?: '',
         stayTime                 : params.stayTime ?: ''
        ]
    }
}
